
             
/**
 * 
 *
 * @File name:  UpdateTSuppliersAction.java   修改【供应商信息:T_SUPPLIERS】
 * @Create on:  2011-10-31 23:59:931
 * @Author   :  陈伟
 *
 * @ChangeList
 * ---------------------------------------------------
 * Date         Editor              ChangeReasons
 *
 */
           
        

package com.boho.estates.suppliers.action;

            
import java.sql.Connection;

import cn.boho.framework.actions.ActionImp;
import cn.boho.framework.context.ActionContext;
import cn.boho.framework.exception.UserOperationException;
import cn.boho.framework.po.POUtils;
import cn.boho.framework.service.MessageService;

import com.boho.common.SystemUtils;
import com.boho.estates.po.TSuppliersPO;
import com.boho.estates.suppliers.common.Constant;
            
        
public class UpdateTSuppliersAction extends ActionImp {
	
	private String exception = "";
	private String suppliersType = "";
	
	private TSuppliersPO conditionTSuppliersPO = new TSuppliersPO();
	private TSuppliersPO valueTSuppliersPO = new TSuppliersPO();
	private Connection con=null;
	@Override
	protected void doException(ActionContext atx, Exception ex) {
		if (!(ex instanceof UserOperationException)) {
			if(Constant.SUPPLIERS_TYPE_X.equalsIgnoreCase(suppliersType)){
				exception = Constant.X_EXCEPTION;
			}
			else if(Constant.SUPPLIERS_TYPE_Z.equalsIgnoreCase(suppliersType)){
				exception = Constant.Z_EXCEPTION;
			}
			atx.setErrorContext("BOHO_COMMON_1002", MessageService.getMessage("BOHO_COMMON_1002"),exception,ex);
		}
	}
	@Override
	protected int performExecute(ActionContext atx) throws Exception {
		POUtils.update(con, conditionTSuppliersPO, valueTSuppliersPO,false);
		return 1;
	}
	@Override
	protected int verifyParameters(ActionContext atx) throws Exception {
		con = atx.getConection();
		suppliersType = atx.getStringValue("SUPPLIERS_TYPE");
		String updateBy = SystemUtils.getSessionUser(atx);
		conditionTSuppliersPO.setSuppliersNo(atx.getIntegerValue("SUPPLIERS_NO",-1));
		valueTSuppliersPO.setSuppliersType(suppliersType);
		valueTSuppliersPO.setSuppliersName(atx.getStringValue("SUPPLIERS_NAME"));
		valueTSuppliersPO.setSuppliersNature(atx.getStringValue("SUPPLIERS_NATURE"));
		valueTSuppliersPO.setContact(atx.getStringValue("CONTACT"));
		valueTSuppliersPO.setTelephone(atx.getStringValue("TELEPHONE"));
		valueTSuppliersPO.setAddress(atx.getStringValue("ADDRESS"));
		valueTSuppliersPO.setAssPhone(atx.getStringValue("ASS_PHONE"));
		valueTSuppliersPO.setFax(atx.getStringValue("FAX"));
		valueTSuppliersPO.setRemark(atx.getStringValue("REMARK"));
		valueTSuppliersPO.setUpdateDate(new java.util.Date());
		valueTSuppliersPO.setUpdateBy(updateBy);
		return 1;
	}
}
